SELECT MAX(id) FROM tablename;
//You need to use this in OpenCart for getting last insert id: $this->db->getLastId()